/*! \file
 * \brief Enter a brief description here.
 *
 * Enter a detailed description here. (optional)
 * \author Author (Ivo Wingelaar)
 * \date Date (2011)
 * \version Version (0.0.1)
 * \copyright Copyright (GNU LGPL v3)
 */

#ifndef __LYNX_MATERIAL_RENDERER_SERVICES_HPP_INCLUDED__
#define __LYNX_MATERIAL_RENDERER_SERVICES_HPP_INCLUDED__

#include "LynxMaterial.hpp"

namespace Lynx
{

class VideoManager;

//! Interface providing some methods for changing advanced, internal states of a IVideoDriver.
class MaterialRendererServices
{
public:

    //! Destructor
    virtual ~MaterialRendererServices() {}

    //! Can be called by an IMaterialRenderer to make its work easier.
    /** Sets all basic renderstates if needed.
    Basic render states are diffuse, ambient, specular, and emissive color,
    specular power, bilinear and trilinear filtering, wireframe mode,
    grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and
    fog enabling.
    \param material The new material to be used.
    \param lastMaterial The material used until now.
    \param resetAllRenderstates Set to true if all renderstates should be
    set, regardless of their current state. */
    virtual void set_basic_render_states(const Material& material, const Material& lastMaterial, bool resetAllRenderstates) = 0;

    //! Sets a constant for the vertex shader based on a name.
    /** This can be used if you used a high level shader language like GLSL
    or HLSL to create a shader. Example: If you created a shader which has
    variables named 'mWorldViewProj' (containing the WorldViewProjection
    matrix) and another one named 'fTime' containing one float, you can set
    them in your IShaderConstantSetCallBack derived class like this:
    \code
    virtual void on_set_constants(video::IMaterialRendererServices* services, s32 userData)
    {
    	video::IVideoDriver* driver = services->getVideoDriver();

    	f32 time = (f32)os::Timer::getTime()/100000.0f;
    	services->set_vertex_shader_constant("fTime", &time, 1);

    	core::matrix4 worldViewProj(driver->get_transform(video::ETS_PROJECTION));
    	worldViewProj *= driver->get_transform(video::ETS_VIEW);
    	worldViewProj *= driver->get_transform(video::ETS_WORLD);
    	services->set_vertex_shader_constant("mWorldViewProj", worldViewProj.M, 16);
    }
    \endcode
    \param name Name of the variable
    \param floats Pointer to array of floats
    \param count Amount of floats in array.
    \return True if successful.
    */
    virtual bool set_vertex_shader_constant(const char* name, const float* floats, int count) = 0;

    //! Sets a vertex shader constant.
    /** Can be used if you created a shader using pixel/vertex shader
    assembler or ARB_fragment_program or ARB_vertex_program.
    \param data: Data to be set in the constants
    \param startRegister: First register to be set
    \param constantAmount: Amount of registers to be set. One register consists of 4 floats. */
    virtual void set_vertex_shader_constant(const float* data, int32_t startRegister, int32_t constantAmount = 1) = 0;

    //! Sets a constant for the pixel shader based on a name.
    /** This can be used if you used a high level shader language like GLSL
    or HLSL to create a shader. See set_vertex_shader_constant() for an
    example on how to use this.
    \param name Name of the variable
    \param floats Pointer to array of floats
    \param count Amount of floats in array.
    \return True if successful. */
    virtual bool set_pixel_shader_constant(const char* name, const float* floats, int count) = 0;

    //! Sets a pixel shader constant.
    /** Can be used if you created a shader using pixel/vertex shader
    assembler or ARB_fragment_program or ARB_vertex_program.
    \param data Data to be set in the constants
    \param startRegister First register to be set.
    \param constantAmount Amount of registers to be set. One register consists of 4 floats. */
    virtual void set_pixel_shader_constant(const float* data, int32_t startRegister, int32_t constantAmount = 1) = 0;

    //! Get pointer to the IVideoDriver interface
    /** \return Pointer to the IVideoDriver interface */
    virtual VideoManager* get_video_manager() = 0;
};

} // namespace Lynx

#endif // __LYNX_MATERIAL_RENDERER_SERVICES_HPP_INCLUDED__

